﻿@inherits AdminCompontentBase

<DefaultSheetDialog @bind-Value=_visible Title="@_title">
    <MCard Class="mx-auto d-flex flex-column full-height">
        <MCardText Class="d-flex align-center full-height">
            <MForm Model="_dto" EnableValidation Class="full-width" EnableI18n @ref="_form">
                <div class="d-flex mb-12">
                    <div class="mx-auto">
                        <SNameTextField @bind-Value="@_dto.Name" style="width:323px;" Placeholder="@T("Enter Name")" />
                    </div>
                </div>
                @if (_dto.ParentId != Guid.Empty)
                {
                    <MCascader Items="Departments" Dense class="mt-6" @bind-Value="@_dto.ParentId"
                           ItemText="u => u.Name" ChangeOnSelect Label="@T("Location")"
                           ItemValue="u => u.Id"
                           ItemChildren="u => u.Children">
                    </MCascader>
                }
                <MTextarea @bind-Value="@_dto.Description" class="mt-6" Label="@T("Description")" Outlined Height="120" NoResize />
            </MForm>
        </MCardText>
        <MCardActions class="d-flex align-center px-6">
            <EnableSwitch @bind-Value="_dto.Enabled" />
            <MSpacer />
            @if (_dto.ParentId != Guid.Empty && _dto.Id != Guid.Empty)
            {
                <SButton Text Color="error" MinWidth="100" OnClick="OnDeleteHandler">
                    @T("Delete")
                </SButton>
            }
            <SButton Medium Disabled="@string.IsNullOrEmpty(_dto.Name.Trim())" OnClick="OnSubmitHandler">@_saveTitle</SButton>
        </MCardActions>
    </MCard>
</DefaultSheetDialog>
